package com.achievement.dao;

import java.util.List;

import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import com.achievement.entity.Course;
@Repository
public interface CourseRepository extends PagingAndSortingRepository<Course, Long>, JpaSpecificationExecutor<Course> {
	@Query(value="from Course c join c.students s where s.id = ?1")
	public List<Object> findByStuId(Long id);
	@Query(value="from Course c where c.id in (:ids)")
	public List<Object> findTest(@Param("ids")List<Long> ids);
	@Query(value="from Course c where c.subject.id=?1")
	public List<Course> findBySubjectId(Long id);
	@Query(value="from Course c where c.num=?1")
	public Course findByNum(String num);
	@Query(value="from Course c where c.teacher.id=?1")
	public List<Course> findByTchId(Long id);
	@Query(value="from Course c left join c.students s where s.id=?1")
	public List<Course> findByStudentId(Long id);
	@Query(value="from Course c where c.teacher.id=?1")
	public List<Course> findByTeacherId(Long id);
}
